package hd3.wordcount;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @Author: laoyu
 * @Date: 2020/6/4 11:02
 * @Description:
 */
public class WcReducer extends Reducer<Text,LongWritable,Text,LongWritable> {
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {
        long counter = 0;
        for (LongWritable value : values) {
            counter+=value.get();
        }
        System.out.println("reducer:"+values+"=="+counter);
        context.write(key,new LongWritable(counter));
    }
}













